using System;
using System.ComponentModel;
using System.Drawing;
using System.Runtime.CompilerServices;
using System.Windows.Forms;
namespace Easislides
{
	public class FrmLaunchShow : Form
	{
		public delegate void Message(int MsgCode, string MsgString);
		private enum MediaPlayerWindowAction
		{
			Show,
			SendToBack,
			Remote_StopShow,
			Remote_ClearScreen,
			Remote_LoadItem,
			Remote_ResumeItem,
			Remote_RepeatItem,
			Remote_StopItem,
			Remote_ResumeItemFromStart,
			Remote_PauseItem,
			Remote_PausePlayItem,
			Remote_LoadLiveCam,
			Remote_UpdateLiveCam,
			Remote_RefreshMediaWindow,
			Remote_SendScreenToBack,
			Remote_GetMediaTimings,
			Remote_ItemPlayingStatus
		}
		private enum LyricsWindowAction
		{
			Show,
			Remote_StopShow,
			Remote_LyricsChanged,
			Remote_ItemChanged,
			Remote_NotationsChanged,
			Remote_WorshipListChanged,
			Remote_LyricsAlertChanged
		}
		private IContainer components = null;
		private Timer TimerSingleScreen;
		private Timer TimerRemote;
		private Timer TimerMouseDown;
		private Timer TimerOpacity;
		private Timer TimerRotate;
		private ImageList imageList1;
		private Timer TimerToFront;
		private bool FormFirstLoad = true;
		private bool StayTopMost = true;
		private MouseButtons mouse_btn;
		private int mousedown_timelapse;
		private string[] InHeaderData = new string[255];
		private ImageTransitionControl LiveScreen = new ImageTransitionControl();
		private int ItemRotationNextTiming = 0;
		private int ItemRotationNextSlideNumber = 0;
		private int prevRefMode = 0;
		private string tempRotateTimings = "";
		private bool FirstItemLoaded = true;
		private bool ItemMediaChangedSinceLiveCam = false;
		private bool FirstItemBeingProcessed = true;
		private bool CursorOverForm = false;
		private bool CurItemRotates = false;
		private string LiveMediaDuration = "";
		private string LiveMediaPosition = "";
		private int intLiveMediaDuration = 0;
		private int intLiveMediaPosition = 0;
		private bool CurMediaDoRotate = false;
		private bool CurMediaPlayingStatus = false;
		private int LoadRepaintCount = 0;
		private Cursor LiveCursor;
		private FrmLaunchMediaPlayer MediaPlayerWindow = new FrmLaunchMediaPlayer();
		private FrmLyricsScreen LyricsWindow = new FrmLyricsScreen();
		public event FrmLaunchShow.Message OnMessage
		{
			[MethodImpl(MethodImplOptions.Synchronized)]
			add
			{
                //this.OnMessage = (FrmLaunchShow.Message)Delegate.Combine(this.OnMessage, value);
			}
			[MethodImpl(MethodImplOptions.Synchronized)]
			remove
			{
                //this.OnMessage = (FrmLaunchShow.Message)Delegate.Remove(this.OnMessage, value);
			}
		}
		protected override void Dispose(bool disposing)
		{
			if (disposing && this.components != null)
			{
				this.components.Dispose();
			}
			base.Dispose(disposing);
		}
		private void InitializeComponent()
		{
            this.components = new System.ComponentModel.Container();
            this.TimerSingleScreen = new System.Windows.Forms.Timer(this.components);
            this.TimerRemote = new System.Windows.Forms.Timer(this.components);
            this.TimerMouseDown = new System.Windows.Forms.Timer(this.components);
            this.TimerOpacity = new System.Windows.Forms.Timer(this.components);
            this.TimerRotate = new System.Windows.Forms.Timer(this.components);
            this.imageList1 = new System.Windows.Forms.ImageList(this.components);
            this.TimerToFront = new System.Windows.Forms.Timer(this.components);
            this.SuspendLayout();
            // 
            // TimerSingleScreen
            // 
            this.TimerSingleScreen.Tick += new System.EventHandler(this.TimerSingleScreen_Tick);
            // 
            // TimerRemote
            // 
            this.TimerRemote.Tick += new System.EventHandler(this.TimerRemote_Tick);
            // 
            // TimerMouseDown
            // 
            this.TimerMouseDown.Enabled = true;
            this.TimerMouseDown.Interval = 200;
            this.TimerMouseDown.Tick += new System.EventHandler(this.TimerMouseDown_Tick);
            // 
            // TimerOpacity
            // 
            this.TimerOpacity.Tick += new System.EventHandler(this.TimerOpacity_Tick);
            // 
            // TimerRotate
            // 
            this.TimerRotate.Interval = 500;
            this.TimerRotate.Tick += new System.EventHandler(this.TimerRotate_Tick);
            // 
            // imageList1
            // 
            this.imageList1.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit;
            this.imageList1.ImageSize = new System.Drawing.Size(16, 16);
            this.imageList1.TransparentColor = System.Drawing.Color.Transparent;
            // 
            // TimerToFront
            // 
            this.TimerToFront.Enabled = true;
            this.TimerToFront.Tick += new System.EventHandler(this.TimerToFront_Tick);
            // 
            // FrmLaunchShow
            // 
            this.BackColor = System.Drawing.Color.Black;
            this.ClientSize = new System.Drawing.Size(124, 72);
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
            this.KeyPreview = true;
            this.Name = "FrmLaunchShow";
            this.ShowIcon = false;
            this.ShowInTaskbar = false;
            this.Text = "Live";
            this.TopMost = true;
            this.TransparencyKey = System.Drawing.Color.FromArgb(((int)(((byte)(128)))), ((int)(((byte)(64)))), ((int)(((byte)(192)))));
            this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FrmLaunchShow_FormClosing);
            this.Load += new System.EventHandler(this.FrmLaunchShow_Load);
            this.VisibleChanged += new System.EventHandler(this.FrmLaunchShow_VisibleChanged);
            this.Enter += new System.EventHandler(this.FrmLaunchShow_Enter);
            this.Leave += new System.EventHandler(this.FrmLaunchShow_Leave);
            this.ResumeLayout(false);

		}
		public FrmLaunchShow()
		{
			this.InitializeComponent();
		}
		private void FrmLaunchShow_Load(object sender, EventArgs e)
		{
			if (this.FormFirstLoad)
			{
				Bitmap bitmap = new Bitmap(55, 25);
				Graphics graphics = Graphics.FromImage(bitmap);
				IntPtr hicon = bitmap.GetHicon();
				this.LiveCursor = new Cursor(hicon);
				this.Cursor = this.LiveCursor;
				this.InitForm();
				this.LiveScreen.MouseUp += new MouseEventHandler(this.FrmLiveShow_MouseUp);
				this.LiveScreen.MouseDown += new MouseEventHandler(this.FrmLiveShow_MouseDown);
				this.MediaPlayerWindow.OnMessage += new FrmLaunchMediaPlayer.Message(this.MediaPlayerWindow_OnMessage);
				this.LyricsWindow.OnMessage += new FrmLyricsScreen.Message(this.LyricsWindow_OnMessage);
				this.LiveScreen.Cursor = this.LiveCursor;
			}
		}
		private void InitForm()
		{
			this.BackColor = gf.TransparentColour;
			base.TransparencyKey = gf.TransparentColour;
			this.LiveScreen.Parent = this;
			this.LiveScreen.Dock = DockStyle.Fill;
			gf.SetLiveShowScreenSaverSettings();
			this.SetShowWindow(true);
			this.TimerSingleScreen.Interval = gf.AlertGap;
			this.TimerRemote.Interval = gf.AlertGap;
			this.TimerMouseDown.Interval = gf.AlertGap;
			this.TimerOpacity.Interval = gf.AlertGap;
			gf.LiveItem.Initialise();
			gf.RestartItemActioned = true;
			gf.SetDefaultBackScreen(ref this.LiveScreen);
			if (gf.LyricsMonitorNumber > 0 || gf.LMOption > 0)
			{
				gf.tbLyricsMonitorSpace.Font = new Font(gf.tbLyricsMonitorSpace.Font.Name, (float)gf.DisplayFontSize(gf.LMMainFontSize, gf.LM_Width, 1, 1), gf.tbLyricsMonitorSpace.Font.Style);
				try
				{
					this.RemoteControlLyricsWindow(FrmLaunchShow.LyricsWindowAction.Show);
				}
				catch
				{
				}
			}
			gf.MediaResetStartTime = true;
			this.ResetMediaSettings();
			this.InitMediaWindow();
			this.FirstItemBeingProcessed = true;
			if (gf.OutputItem.Type == "G")
			{
				string text = "";
				gf.LiveItem.CurItemNo = gf.StartPresAt;
				this.LoadItem(ref gf.LiveItem, "G1", "", 0, ref text, ImageTransitionControl.TransitionAction.None, false);
			}
			else
			{
				this.LoadWorshipListItemToLive(gf.AdHocItemPresent ? 0 : gf.StartPresAt, gf.OutputItem.CurSlide, ImageTransitionControl.TransitionAction.AsStored);
			}
			if (gf.MessageAlertRequested)
			{
				this.Remote_MessageAlertRequested();
			}
			else
			{
				if (gf.ParentalAlertRequested)
				{
					this.Remote_ParentalAlertRequested();
				}
			}
			this.FirstItemBeingProcessed = false;
			if (gf.ShowLiveCam)
			{
				this.Remote_LiveCamStartStop();
			}
			if (gf.DualMonitorMode)
			{
				base.TopMost = true;
			}
			else
			{
				gf.HideTaskBar();
				this.SetScreenOnTop(true);
			}
		}
		private void InitMediaWindow()
		{
			if (gf.WMP_Present)
			{
				try
				{
					this.RemoteControlMediaPlayerWindow(FrmLaunchShow.MediaPlayerWindowAction.Show);
					this.RemoteControlMediaPlayerWindow(FrmLaunchShow.MediaPlayerWindowAction.SendToBack);
				}
				catch
				{
				}
			}
		}
		private void MediaPlayerWindow_OnMessage(int MsgCode, string MsgString)
		{
			if (MsgCode != 3)
			{
				switch (MsgCode)
				{
				case 11:
					this.DoMouseDown(MouseButtons.Left);
					break;
				case 12:
					this.DoMouseDown(MouseButtons.Right);
					break;
				case 13:
					this.DoMouseUp();
					break;
				}
			}
			else
			{
				this.Remote_ItemIsVideo();
			}
		}
		private void LyricsWindow_OnMessage(int MsgCode, string MsgString)
		{
			switch (MsgCode)
			{
			case 3:
				this.Remote_ItemIsVideo();
				break;
			case 4:
				this.Remote_ItemIsNotVideo();
				break;
			}
		}
		public void Remote_ItemIsVideo()
		{
			gf.LiveItem.Format.MediaTransparent = true;
			gf.MediaCurrentItemIsVideo = true;
			this.ShowSlide(ref gf.LiveItem, ImageTransitionControl.TransitionAction.None);
			gf.MinimizePowerPointWindows(ref gf.LivePP);
		}
		public void Remote_ItemIsNotVideo()
		{
			gf.MediaCurrentItemIsVideo = false;
			gf.LiveItem.Format.MediaTransparent = false;
		}
		public void Remote_WorshipListChanged()
		{
			this.RemoteControlLyricsWindow(FrmLaunchShow.LyricsWindowAction.Remote_WorshipListChanged);
		}
		public void Remote_LiveCamStartStop()
		{
			if (gf.ShowLiveCam)
			{
				this.CurMediaDoRotate = gf.MediaDoRotate;
				this.TimerRotate.Stop();
				this.RemoteControlMediaPlayerWindow(FrmLaunchShow.MediaPlayerWindowAction.Remote_LoadLiveCam);
				this.ShowSlide(ref gf.LiveItem, ImageTransitionControl.TransitionAction.None);
				this.ItemMediaChangedSinceLiveCam = false;
				gf.MinimizePowerPointWindows(ref gf.LivePP);
			}
			else
			{
				if (gf.LiveItem.Type == "P")
				{
					gf.RunPowerpointSong(ref gf.LiveItem, ref gf.LivePP, gf.LiveItem.CurSlide);
				}
				if (this.ItemMediaChangedSinceLiveCam)
				{
					this.Remote_SongChanged(true);
				}
				else
				{
					gf.MediaLiveItemStartTime = DateTime.Now.Subtract(gf.MediaPlayedLapseTime);
					this.TimerRotate.Start();
					this.RemoteControlMediaPlayerWindow(FrmLaunchShow.MediaPlayerWindowAction.Remote_ResumeItem);
					gf.MediaDoRotate = this.CurMediaDoRotate;
					if (gf.MediaDoRotate)
					{
						this.RemoteControlMediaPlayerWindow(FrmLaunchShow.MediaPlayerWindowAction.Remote_GetMediaTimings);
						gf.MediaLiveItemStartTime = DateTime.Now.Subtract(new TimeSpan(0, 0, this.intLiveMediaPosition));
					}
					this.ShowSlide(ref gf.LiveItem, ImageTransitionControl.TransitionAction.None, false, true);
				}
			}
		}
		public void Remote_LiveCamUpdate()
		{
			if (gf.ShowLiveCam)
			{
				this.RemoteControlMediaPlayerWindow(FrmLaunchShow.MediaPlayerWindowAction.Remote_UpdateLiveCam);
			}
		}
		private void SetShowWindow(bool max)
		{
			if (max)
			{
				base.Left = gf.LS_Left;
				base.Top = gf.LS_Top;
				base.Height = gf.LS_Height;
				base.Width = gf.LS_Width;
			}
			else
			{
				base.Left = gf.LS_Left;
				base.Top = gf.LS_Top;
				base.Height = 0;
				base.Width = 0;
			}
		}
		private void SetScreenOnTop(bool StartTimer)
		{
			this.StayTopMost = StartTimer;
			base.TopMost = this.StayTopMost;
			if (StartTimer && !gf.DualMonitorMode)
			{
				Cursor.Position = new Point(gf.LS_Left, gf.LS_Height - 1);
				this.TimerSingleScreen.Start();
			}
			else
			{
				this.TimerSingleScreen.Stop();
			}
		}
		private void TimerOpacity_Tick(object sender, EventArgs e)
		{
			base.Opacity = 100.0;
			this.TimerOpacity.Enabled = false;
		}
		private void FrmLaunchShow_FormClosing(object sender, FormClosingEventArgs e)
		{
			this.FormClosingCleanup();
		}
		private void FormClosingCleanup()
		{
			gf.ResetShowRunningSettings();
			gf.MessageAlertLive = false;
			gf.ParentalAlertLive = false;
			gf.ShowRunning = false;
			this.TimerRotate.Stop();
			this.TimerSingleScreen.Stop();
			this.TimerRemote.Stop();
			this.TimerMouseDown.Stop();
			gf.OutputItem.Type = gf.LiveItem.Type;
			gf.OutputItem.CurItemNo = ((gf.LiveItem.CurItemNo < 0) ? 1 : gf.LiveItem.CurItemNo);
			gf.OutputItem.CurSlide = ((gf.LiveItem.CurSlide < 1) ? 1 : gf.LiveItem.CurSlide);
			gf.RestoreScreenSaverSettings();
			gf.ClearUpPowerpointWindows();
			gf.RefreshWindowsDesktop();
			gf.ShowTaskBar();
		}
		public void StopShow()
		{
			try
			{
				this.RemoteControlMediaPlayerWindow(FrmLaunchShow.MediaPlayerWindowAction.Remote_StopShow);
				gf.DrawText(ref gf.LiveItem, ref this.LiveScreen, gf.LiveItem.LyricsAndNotationsList, false, true);
			}
			catch
			{
			}
			try
			{
				this.RemoteControlLyricsWindow(FrmLaunchShow.LyricsWindowAction.Remote_StopShow);
			}
			catch
			{
			}
			this.FormClosingCleanup();
			base.Hide();
			gf.RefreshWindowsDesktop();
		}
		public void Remote_DefaultBackgroundChanged()
		{
			gf.SetDefaultBackScreen(ref this.LiveScreen);
			gf.SetShowBackground(gf.LiveItem, ref this.LiveScreen);
			this.ShowSlide(ref gf.LiveItem, ImageTransitionControl.TransitionAction.None);
		}
		public void Remote_BackgroundChanged()
		{
			gf.SetShowBackground(gf.LiveItem, ref this.LiveScreen);
			this.ShowSlide(ref gf.LiveItem, ImageTransitionControl.TransitionAction.None);
		}
		public void Remote_MoveToItemChanged()
		{
			this.MoveToLiveItem(gf.LiveItem, gf.MainAction_MoveToItemKeyDirection, gf.OutputItem.CurSlide);
		}
		public void Remote_SongChanged(bool ReLoadIfCaptureDevice)
		{
			if (gf.OutputItem.Type == "G")
			{
				this.ShowSlide(ref gf.LiveItem, ImageTransitionControl.TransitionAction.None);
			}
			else
			{
				this.LoadWorshipListItemToLive(gf.DualMonitorMode ? gf.OutputItem.CurItemNo : gf.LiveItem.CurItemNo, gf.OutputItem.CurSlide, gf.MainAction_SongChanged_Transaction, ReLoadIfCaptureDevice);
			}
			gf.LaunchShowUpdateDone = true;
		}
		public void Remote_SlideChanged(int InDirection)
		{
			if (gf.LiveItem.CurItemNo == gf.OutputItem.CurItemNo)
			{
				if (gf.LiveItem.Type == "P")
				{
					gf.LiveItem.CurSlide = gf.OutputItem.CurSlide;
					this.MoveToSlideLiveItem(gf.LiveItem, gf.KeyDirection.Refresh);
				}
				else
				{
					gf.LiveItem.CurSlide = gf.OutputItem.CurSlide;
					this.MoveToSlideLiveItem(gf.LiveItem, gf.KeyDirection.Refresh);
				}
			}
			else
			{
				this.LoadWorshipListItemToLive(gf.OutputItem.CurItemNo, gf.OutputItem.CurSlide, ImageTransitionControl.TransitionAction.AsStored);
			}
		}
		public void Remote_SongJumpTo()
		{
			if (gf.OutputItem.Type == "G")
			{
				string text = "";
				this.LoadItem(ref gf.LiveItem, "G1", "", 0, ref text, ImageTransitionControl.TransitionAction.None, false);
			}
			else
			{
				this.MoveToLiveItem(gf.LiveItem, gf.KeyDirection.Refresh);
			}
		}
		public void Remote_LiveBlackClearChanged()
		{
			if (gf.LiveItem.Type == "P")
			{
				gf.DrawText(ref gf.LiveItem, ref this.LiveScreen, gf.LiveItem.LyricsAndNotationsList, false, false);
			}
			else
			{
				this.ShowSlide(ref gf.LiveItem, gf.GapItemUseFade ? ImageTransitionControl.TransitionAction.AsFade : ImageTransitionControl.TransitionAction.None);
			}
		}
		public void Remote_FormatChanged()
		{
			if (gf.LiveItem.Type != "P")
			{
				this.RefreshSlidesFonts(ref gf.LiveItem, gf.MainAction_SongChanged_Transaction);
			}
		}
		public void Remote_PanelChanged()
		{
			if (gf.LiveItem.Type == "P")
			{
				gf.DrawText(ref gf.LiveItem, ref this.LiveScreen, gf.LiveItem.LyricsAndNotationsList, false, false);
			}
			else
			{
				this.RefreshSlidesFonts(ref gf.LiveItem, gf.MainAction_SongChanged_Transaction);
			}
		}
		public void Remote_ChineseChanged()
		{
			gf.SwitchChineseLyricsNotationListView(ref gf.LiveItem, gf.SwitchChinese(ref gf.LiveItem.CompleteLyrics));
			if (gf.LiveItem.Type != "P")
			{
				this.ShowSlide(ref gf.LiveItem, ImageTransitionControl.TransitionAction.None);
			}
		}
		public void Remote_MessageAlertRequested()
		{
			gf.MessageAlertRequested = false;
			gf.AlertSettings(gf.AlertType.Message);
			this.LiveScreen.StartAlert(gf.LiveItem, gf.Alert_OriginalMessage, gf.AlertTimeRemaining, gf.Alert_UserFont, gf.Alert_Scroll, gf.Alert_Flash, gf.Alert_Transparent, gf.Alert_UserFontShadow, gf.Alert_UserFontOutline, gf.Alert_TextColour, gf.Alert_BackColour, gf.Alert_TextAlign, gf.Alert_VerticalAlign, gf.BottomBorderFactor);
		}
		public void Remote_ParentalAlertRequested()
		{
			gf.ParentalAlertRequested = false;
			gf.AlertSettings(gf.AlertType.Parental);
			this.LiveScreen.StartAlert(gf.LiveItem, gf.Alert_OriginalMessage, gf.AlertTimeRemaining, gf.Alert_UserFont, gf.Alert_Scroll, gf.Alert_Flash, gf.Alert_Transparent, gf.Alert_UserFontShadow, gf.Alert_UserFontOutline, gf.Alert_TextColour, gf.Alert_BackColour, gf.Alert_TextAlign, gf.Alert_VerticalAlign, gf.BottomBorderFactor);
		}
		public void Remote_ReferenceAlertRequested(bool NewStatus)
		{
			this.QueryShowActive(NewStatus);
		}
		public void Remote_LyricsAlertRequested()
		{
			gf.LyricsAlertRequested = false;
			this.RemoteControlLyricsWindow(FrmLaunchShow.LyricsWindowAction.Remote_LyricsAlertChanged);
		}
		public void Remote_RotateOnOffChanged()
		{
			this.TimerRotate.Start();
		}
		public void Remote_StopShow()
		{
			try
			{
				this.RemoteControlMediaPlayerWindow(FrmLaunchShow.MediaPlayerWindowAction.Remote_StopShow);
			}
			catch
			{
			}
		}
		public void Remote_RefreshMediaWindow()
		{
			try
			{
				this.RemoteControlMediaPlayerWindow(FrmLaunchShow.MediaPlayerWindowAction.Remote_RefreshMediaWindow);
			}
			catch
			{
			}
		}
		public string Remote_GetMediaTimings()
		{
			string result;
			if (gf.ShowLiveCam)
			{
				result = "";
			}
			else
			{
				string text = "";
				if (gf.AutoRotateOn && this.CurItemRotates)
				{
					this.LiveMediaPosition = new DateTime(gf.MediaPlayedLapseTime.Ticks).ToString("mm:ss");
					TimeSpan timeSpan = new TimeSpan(0, 0, gf.LiveItem.RotateTotal);
					this.LiveMediaDuration = new DateTime(timeSpan.Ticks).ToString("mm:ss");
					text = this.LiveMediaPosition + ((gf.LiveItem.RotateTotal > 0) ? (" [" + this.LiveMediaDuration + "]") : "");
				}
				else
				{
					if (gf.LiveItem.Type == "M")
					{
						this.RemoteControlMediaPlayerWindow(FrmLaunchShow.MediaPlayerWindowAction.Remote_GetMediaTimings);
						if (this.LiveMediaDuration != "")
						{
							text = this.LiveMediaPosition + " [" + this.LiveMediaDuration + "]";
						}
					}
				}
				result = text;
			}
			return result;
		}
		public string Remote_MediaItemPausePlay()
		{
			if (gf.CurrentMediaLocation != "" && !gf.ShowLiveCam)
			{
				this.RemoteControlMediaPlayerWindow(FrmLaunchShow.MediaPlayerWindowAction.Remote_PausePlayItem);
				gf.MediaDoRotate = false;
			}
			return "";
		}
		private void TimerRemote_Tick(object sender, EventArgs e)
		{
		}
		private void TimerSingleScreen_Tick(object sender, EventArgs e)
		{
			base.TopMost = this.StayTopMost;
			if (this.StayTopMost && Cursor.Position.X >= base.Left && Cursor.Position.X <= base.Left + base.Width && Cursor.Position.Y >= base.Top && Cursor.Position.Y <= base.Top + base.Bottom)
			{
				base.Activate();
				Cursor.Position = new Point(gf.LS_Left, gf.LS_Height - 1);
			}
		}
		private void TimerMouseDown_Tick(object sender, EventArgs e)
		{
			if (!gf.DualMonitorMode)
			{
				this.mousedown_timelapse += gf.AlertGap;
			}
			else
			{
				this.TimerMouseDown.Stop();
			}
		}
		private void ItemKeyPressed(gf.SongSettings InItem, Keys KeyCode)
		{
			if (gf.DualMonitorMode)
			{
				gf.ReMapKeyBoard(ref KeyCode);
				if (KeyCode == Keys.Escape || KeyCode == Keys.Subtract || KeyCode == Keys.OemMinus || KeyCode == Keys.F12)
				{
                    //this.OnMessage(10, "");
				}
			}
			else
			{
				gf.ReMapKeyBoard(ref KeyCode);
				if (KeyCode == Keys.Escape || KeyCode == Keys.Subtract || KeyCode == Keys.OemMinus || KeyCode == Keys.F12)
				{
					this.StopShow();
				}
				else
				{
					if (KeyCode == Keys.F1)
					{
						this.SetScreenOnTop(false);
                        //FrmHelp frmHelp = new FrmHelp();
                        //frmHelp.ShowDialog();
                        //this.SetScreenOnTop(true);
					}
					else
					{
						if (KeyCode == Keys.F2)
						{
							gf.ShowLiveBlack = !gf.ShowLiveBlack;
							this.ShowSlide(ref gf.LiveItem, gf.GapItemUseFade ? ImageTransitionControl.TransitionAction.AsFade : ImageTransitionControl.TransitionAction.None);
						}
						else
						{
							if (KeyCode == Keys.F3)
							{
								gf.ShowLiveClear = !gf.ShowLiveClear;
								this.ShowSlide(ref gf.LiveItem, gf.GapItemUseFade ? ImageTransitionControl.TransitionAction.AsFade : ImageTransitionControl.TransitionAction.None);
							}
							else
							{
								if (KeyCode == Keys.F4)
								{
									gf.ShowLiveCam = !gf.ShowLiveCam;
									this.Remote_LiveCamStartStop();
								}
								else
								{
									if (KeyCode == Keys.F5)
									{
                                        //gf.RestartItemActioned = false;
                                        //gf.AutoRotateOn = false;
                                        //this.MoveToLiveItem(InItem, gf.KeyDirection.Refresh);
									}
									else
									{
										if (KeyCode == Keys.F9)
										{
											this.SetScreenOnTop(false);
											FrmSingleMonitorAlert frmSingleMonitorAlert = new FrmSingleMonitorAlert();
											DialogResult dialogResult = frmSingleMonitorAlert.ShowDialog();
											if (dialogResult == DialogResult.OK)
											{
												this.LiveScreen.StartAlert(gf.LiveItem, gf.Alert_OriginalMessage, gf.AlertTimeRemaining, gf.Alert_UserFont, gf.Alert_Scroll, gf.Alert_Flash, gf.Alert_Transparent, gf.Alert_UserFontShadow, gf.Alert_UserFontOutline, gf.Alert_TextColour, gf.Alert_BackColour, gf.Alert_TextAlign, gf.Alert_VerticalAlign, gf.BottomBorderFactor);
											}
											this.SetScreenOnTop(true);
										}
										else
										{
											if (KeyCode == Keys.F10)
											{
												gf.SwitchChineseLyricsNotationListView(ref gf.LiveItem, gf.SwitchChinese(ref gf.LiveItem.CompleteLyrics));
												this.ShowSlide(ref gf.LiveItem, ImageTransitionControl.TransitionAction.None);
											}
											else
											{
												if (KeyCode == Keys.A)
												{
													gf.AutoRotateOn = !gf.AutoRotateOn;
													gf.RestartCurrentItem = false;
													this.TimerRotate.Start();
												}
												else
												{
													if (KeyCode == Keys.M)
													{
														this.Remote_MediaItemPausePlay();
													}
													else
													{
														if (KeyCode == Keys.J)
														{
															if (InItem.OutputStyleScreen)
															{
																this.GotoNextNonRotateItem();
															}
														}
														else
														{
															if (KeyCode == Keys.D)
															{
																this.ToggleShowDataDisplayMode();
															}
															else
															{
																if (KeyCode == Keys.H)
																{
																	this.ToggleShowHeader();
																}
																else
																{
																	if (KeyCode == Keys.R)
																	{
																		this.ToggleShowLyrics();
																	}
																	else
																	{
																		if (KeyCode == Keys.S)
																		{
																			this.ToggleUseShadowFont();
																		}
																		else
																		{
																			if (KeyCode == Keys.O)
																			{
																				this.ToggleUseOutlineFont();
																			}
																			else
																			{
																				if (KeyCode == Keys.I)
																				{
																					this.ToggleInterlace();
																				}
																				else
																				{
																					if (KeyCode == Keys.V)
																					{
																						this.ToggleVerticalAlignment();
																					}
																					else
																					{
																						if (KeyCode == Keys.N)
																						{
																							this.ToggleShowNotations();
																						}
																						else
																						{
																							if (KeyCode == Keys.Home)
																							{
																								this.MoveToLiveItem(InItem, gf.KeyDirection.FirstOne);
																							}
																							else
																							{
																								if (KeyCode == Keys.Prior)
																								{
																									this.MoveToLiveItem(InItem, gf.KeyDirection.PrevOne);
																								}
																								else
																								{
																									if (KeyCode == Keys.Next || KeyCode == Keys.Tab)
																									{
																										this.MoveToLiveItem(InItem, gf.KeyDirection.NextOne);
																									}
																									else
																									{
																										if (KeyCode == Keys.End)
																										{
																											this.MoveToLiveItem(InItem, gf.KeyDirection.LastOne);
																										}
																										else
																										{
																											if (KeyCode == Keys.Tab)
																											{
																												this.MoveToLiveItem(InItem, gf.KeyDirection.NextOne);
																											}
																											else
																											{
																												if (KeyCode == Keys.Up)
																												{
																													this.MoveToSlideLiveItem(InItem, gf.KeyDirection.PrevOne);
																												}
																												else
																												{
																													if (KeyCode == Keys.Left)
																													{
																														this.MoveToSlideLiveItem(InItem, gf.KeyDirection.FirstOne);
																													}
																													else
																													{
																														if (KeyCode == Keys.Right)
																														{
																															this.MoveToSlideLiveItem(InItem, gf.KeyDirection.LastOne);
																														}
																														else
																														{
																															if (KeyCode == Keys.Down)
																															{
																																if (InItem.CurSlide < InItem.TotalSlides || gf.AdvanceNextItem)
																																{
																																	this.MoveToSlideLiveItem(InItem, gf.KeyDirection.NextOne);
																																}
																															}
																															else
																															{
																																if (KeyCode == Keys.Space)
																																{
																																	this.MoveToSlideLiveItem(InItem, gf.KeyDirection.NextOne);
																																}
																																else
																																{
																																	if (KeyCode == Keys.G)
																																	{
																																		if (gf.GapItemOption == gf.GapType.None)
																																		{
																																			gf.GapItemOption = gf.AltGapItemOption;
																																			gf.AltGapItemOption = gf.GapType.None;
																																		}
																																		else
																																		{
																																			gf.AltGapItemOption = gf.GapItemOption;
																																			gf.GapItemOption = gf.GapType.None;
																																		}
																																	}
																																	else
																																	{
																																		if (KeyCode == Keys.W || KeyCode == (Keys)65602)
																																		{
																																			this.JumpToVerseType(InItem, 103);
																																		}
																																		else
																																		{
																																			if (KeyCode == Keys.B)
																																			{
																																				this.JumpToVerseType(InItem, 100);
																																			}
																																			else
																																			{
																																				if (KeyCode == Keys.Q || KeyCode == (Keys)65616)
																																				{
																																					this.JumpToVerseType(InItem, 112);
																																				}
																																				else
																																				{
																																					if (KeyCode == Keys.P)
																																					{
																																						this.JumpToVerseType(InItem, 111);
																																					}
																																					else
																																					{
																																						if (KeyCode == Keys.E)
																																						{
																																							this.JumpToVerseType(InItem, 101);
																																						}
																																						else
																																						{
																																							if (KeyCode == Keys.Z)
																																							{
																																								this.QueryShowActive(!this.LiveScreen.RefStatus());
																																							}
																																							else
																																							{
																																								if (KeyCode == Keys.T || KeyCode == (Keys)65603)
																																								{
																																									this.JumpToVerseType(InItem, 102);
																																								}
																																								else
																																								{
																																									if (KeyCode == Keys.C)
																																									{
																																										KeyCode = Keys.D0;
																																									}
																																									else
																																									{
																																										if (KeyCode != Keys.D0)
																																										{
																																											if (KeyCode != Keys.D1)
																																											{
																																												if (KeyCode != Keys.D2)
																																												{
																																													if (KeyCode != Keys.D3)
																																													{
																																														if (KeyCode != Keys.D4)
																																														{
																																															if (KeyCode != Keys.D5)
																																															{
																																																if (KeyCode != Keys.D6)
																																																{
																																																	if (KeyCode != Keys.D7)
																																																	{
																																																		if (KeyCode != Keys.D8)
																																																		{
																																																			if (KeyCode != Keys.D9)
																																																			{
																																																				goto IL_6B2;
																																																			}
																																																		}
																																																	}
																																																}
																																															}
																																														}
																																													}
																																												}
																																											}
																																										}
																																									}
																																									if (InItem.SongVerses[KeyCode - Keys.D0] > 0)
																																									{
																																										InItem.CurSlide = InItem.SongVerses[KeyCode - Keys.D0];
																																										this.MoveToSlideLiveItem(InItem, gf.KeyDirection.Refresh);
																																										KeyCode = Keys.None;
																																									}
																																								}
																																							}
																																						}
																																					}
																																				}
																																			}
																																		}
																																	}
																																}
																															}
																														}
																													}
																												}
																											}
																										}
																									}
																								}
																							}
																						}
																					}
																				}
																			}
																		}
																	}
																}
															}
														}
													}
												}
											}
										}
									}
								}
							}
						}
					}
				}
				IL_6B2:;
			}
		}
		private void QueryShowActive(bool NewStatus)
		{
			if (NewStatus)
			{
				this.ShowSlide(ref gf.LiveItem, ImageTransitionControl.TransitionAction.None, true, false);
			}
			else
			{
				this.LiveScreen.StopRef();
			}
		}
		private void JumpToVerseType(gf.SongSettings InItem, int InOtherVerse)
		{
			for (int i = 1; i <= InItem.TotalSlides; i++)
			{
				if (InItem.Slide[i, 0] == InOtherVerse)
				{
					InItem.CurSlide = i;
					this.MoveToSlideLiveItem(InItem, gf.KeyDirection.Refresh);
					break;
				}
			}
		}
		private void ToggleShowDataDisplayMode()
		{
			gf.ShowDataDisplayMode = ((gf.ShowDataDisplayMode > 0) ? 0 : 1);
			this.ShowSlide(ref gf.LiveItem, ImageTransitionControl.TransitionAction.None);
		}
		private void ToggleShowHeader()
		{
			gf.ShowRunning_ShowSongHeadings = ((gf.ShowRunning_ShowSongHeadings > 0) ? 0 : 1);
			this.ShowSlide(ref gf.LiveItem, ImageTransitionControl.TransitionAction.None);
		}
		private void ToggleUseShadowFont()
		{
			gf.ShowRunning_UseShadowFont = ((gf.ShowRunning_UseShadowFont > 0) ? 0 : 1);
			this.ShowSlide(ref gf.LiveItem, ImageTransitionControl.TransitionAction.None);
		}
		private void ToggleUseOutlineFont()
		{
			gf.ShowRunning_UseOutlineFont = ((gf.ShowRunning_UseOutlineFont > 0) ? 0 : 1);
			this.ShowSlide(ref gf.LiveItem, ImageTransitionControl.TransitionAction.None);
		}
		private void ToggleShowNotations()
		{
			gf.ShowRunning_ShowNotations = ((gf.ShowRunning_ShowNotations > 0) ? 0 : 1);
			this.ShowSong(ref gf.LiveItem, 1, ImageTransitionControl.TransitionAction.None);
			this.RemoteControlLyricsWindow(FrmLaunchShow.LyricsWindowAction.Remote_ItemChanged);
		}
		private void ToggleInterlace()
		{
			gf.ShowRunning_ShowInterlace = ((gf.ShowRunning_ShowInterlace > 0) ? 0 : 1);
			this.ShowSlide(ref gf.LiveItem, ImageTransitionControl.TransitionAction.None);
		}
		private void ToggleVerticalAlignment()
		{
			if (gf.ShowRunning_ShowVerticalAlign == 0)
			{
				gf.ShowRunning_ShowVerticalAlign = 1;
			}
			else
			{
				if (gf.ShowRunning_ShowVerticalAlign == 1)
				{
					gf.ShowRunning_ShowVerticalAlign = 2;
				}
				else
				{
					if (gf.ShowRunning_ShowVerticalAlign == 2)
					{
						gf.ShowRunning_ShowVerticalAlign = 0;
					}
				}
			}
			this.ShowSlide(ref gf.LiveItem, ImageTransitionControl.TransitionAction.None);
		}
		private void ToggleShowLyrics()
		{
			if (gf.ShowRunning_ShowLyrics == 0)
			{
				gf.ShowRunning_ShowLyrics = 1;
			}
			else
			{
				if (gf.ShowRunning_ShowLyrics == 1)
				{
					gf.ShowRunning_ShowLyrics = 2;
				}
				else
				{
					if (gf.ShowRunning_ShowLyrics == 2)
					{
						gf.ShowRunning_ShowLyrics = 0;
					}
				}
			}
			this.ShowSlide(ref gf.LiveItem, ImageTransitionControl.TransitionAction.None);
		}
		private void FrmLiveShow_MouseDown(object sender, MouseEventArgs e)
		{
			this.DoMouseDown(e.Button);
		}
		public void DoMouseDown(MouseButtons InBtn)
		{
			if (!gf.DualMonitorMode)
			{
				this.mouse_btn = InBtn;
				this.mousedown_timelapse = 0;
				this.TimerMouseDown.Start();
			}
		}
		private void FrmLiveShow_MouseUp(object sender, MouseEventArgs e)
		{
			this.DoMouseUp();
		}
		public void DoMouseUp()
		{
			if (!gf.DualMonitorMode)
			{
				if (this.mousedown_timelapse < 400)
				{
					if (this.mouse_btn == MouseButtons.Left)
					{
						this.MoveToSlideLiveItem(gf.LiveItem, gf.KeyDirection.NextOne);
					}
					else
					{
						if (this.mouse_btn == MouseButtons.Right)
						{
							this.MoveToSlideLiveItem(gf.LiveItem, gf.KeyDirection.PrevOne);
						}
					}
				}
				else
				{
					if (this.mouse_btn == MouseButtons.Left)
					{
						this.MoveToLiveItem(gf.LiveItem, gf.KeyDirection.NextOne);
					}
					else
					{
						if (this.mouse_btn == MouseButtons.Right)
						{
							this.MoveToLiveItem(gf.LiveItem, gf.KeyDirection.PrevOne);
						}
					}
				}
				this.mousedown_timelapse = 0;
				this.TimerMouseDown.Stop();
			}
		}
		protected override bool ProcessCmdKey(ref System.Windows.Forms.Message msg, Keys keyData)
		{
			this.ItemKeyPressed(gf.LiveItem, keyData);
			return base.ProcessCmdKey(ref msg, keyData);
		}
		private bool ShowSlide(ref gf.SongSettings InItem, ImageTransitionControl.TransitionAction TransitionAction)
		{
			return this.ShowSlide(ref InItem, TransitionAction, false, false);
		}
		private bool ShowSlide(ref gf.SongSettings InItem, ImageTransitionControl.TransitionAction TransitionAction, bool DoActiveIndicator, bool RedoBackground)
		{
			bool result;
			if (InItem.Type == "P")
			{
				if ((gf.DualMonitorMode && gf.NoPowerpointPanelOverlay && InItem.Type == "P") || (gf.DualMonitorMode && gf.LiveCamNoPanelOverlay && gf.ShowLiveCam))
				{
					this.SetShowWindow(false);
				}
				else
				{
					this.SetShowWindow(true);
				}
				gf.LivePP.ImplementPowerpointSlideMovement(ref InItem.CurSlide, InItem.TotalSlides, Keys.None, InItem.CurSlide);
				if (gf.ShowLiveCam)
				{
					gf.SetTransparentBackground(InItem, ref this.LiveScreen);
				}
				gf.DrawText(ref InItem, ref this.LiveScreen, InItem.LyricsAndNotationsList, false, false);
				this.RemoteControlLyricsWindow(FrmLaunchShow.LyricsWindowAction.Remote_LyricsChanged);
				result = true;
			}
			else
			{
				if (TransitionAction == ImageTransitionControl.TransitionAction.AsStored)
				{
				}
				if ((gf.DualMonitorMode && gf.NoMediaPanelOverlay && InItem.Type == "M") || (gf.DualMonitorMode && gf.LiveCamNoPanelOverlay && gf.ShowLiveCam))
				{
					this.SetShowWindow(false);
				}
				else
				{
					this.SetShowWindow(true);
				}
				InItem.TotalItems = gf.TotalWorshipListItems;
				bool flag = gf.ShowDBSlide(ref InItem, ref this.LiveScreen, DoActiveIndicator, TransitionAction, RedoBackground);
				if (!flag)
				{
					gf.ResetPictureBox(ref InItem, ref this.LiveScreen, gf.GapType.Default, TransitionAction);
				}
				this.RemoteControlLyricsWindow(FrmLaunchShow.LyricsWindowAction.Remote_LyricsChanged);
				result = flag;
			}
			return result;
		}
		private void ShowSong(ref gf.SongSettings InItem, int StartingSlide, ImageTransitionControl.TransitionAction TransitionAction)
		{
			InItem.CurSlide = StartingSlide;
			this.RefreshSlidesFonts(ref InItem, TransitionAction);
		}
		private bool RefreshSlidesFonts(ref gf.SongSettings InItem, ImageTransitionControl.TransitionAction TransitionAction)
		{
			gf.FormatText(ref InItem, gf.PanelBackColour, gf.PanelBackColourTransparent, gf.PanelTextColour, gf.PanelTextColourAsRegion1, InItem.UseDefaultFormat);
			gf.FormatDisplayLyrics(ref InItem, true, true);
			gf.DisplaySlidesFormattedLyrics(ref InItem, ref gf.tbLyricsMonitorSpace, true, gf.LMShowNotations);
			return this.ShowSlide(ref InItem, TransitionAction);
		}
		private void MoveToLiveItem(gf.SongSettings InItem, gf.KeyDirection InIndex)
		{
			this.MoveToLiveItem(InItem, InIndex, 0);
		}
		private void MoveToLiveItem(gf.SongSettings InItem, gf.KeyDirection InDirection, int SlideNo)
		{
			gf.Launch_StartPresAt = (gf.DualMonitorMode ? gf.Launch_StartPresAt : gf.StartPresAt);
			if (InDirection == gf.KeyDirection.FirstOne)
			{
				this.LoadWorshipListItemToLive(1, SlideNo, ImageTransitionControl.TransitionAction.AsStored);
			}
			else
			{
				if (InDirection == gf.KeyDirection.PrevOne)
				{
					if (gf.Launch_StartPresAt <= gf.TotalWorshipListItems)
					{
						this.LoadWorshipListItemToLive(gf.AdHocItemPresent ? gf.Launch_StartPresAt : (gf.Launch_StartPresAt - ((InItem.Type == "G") ? 0 : 1)), SlideNo, ImageTransitionControl.TransitionAction.AsStored);
					}
				}
				else
				{
					if (InDirection == gf.KeyDirection.NextOne)
					{
						if (gf.GapItemOption == gf.GapType.None)
						{
							this.LoadWorshipListItemToLive(gf.Launch_StartPresAt + 1, SlideNo, ImageTransitionControl.TransitionAction.AsStored);
						}
						else
						{
							if (gf.Launch_StartPresAt <= gf.TotalWorshipListItems && (gf.Launch_StartPresAt == 0 || (InItem.Type == "G" && gf.Launch_StartPresAt != gf.TotalWorshipListItems)))
							{
								this.LoadWorshipListItemToLive(gf.Launch_StartPresAt + 1, SlideNo, ImageTransitionControl.TransitionAction.AsStored);
							}
							else
							{
								string text = "";
								this.LoadItem(ref InItem, "G1", "", 0, ref text, ImageTransitionControl.TransitionAction.None, false);
							}
						}
					}
					else
					{
						if (InDirection == gf.KeyDirection.LastOne)
						{
							this.LoadWorshipListItemToLive(gf.TotalWorshipListItems, SlideNo, ImageTransitionControl.TransitionAction.AsStored);
						}
						else
						{
							this.LoadWorshipListItemToLive(gf.Launch_StartPresAt, SlideNo, ImageTransitionControl.TransitionAction.AsStored);
						}
					}
				}
			}
		}
		private void OldDoGapItem(gf.SongSettings InItem)
		{
		}
		private bool LoadWorshipListItemToLive(int Selecteditem, int SlideNo, ImageTransitionControl.TransitionAction TransitionAction)
		{
			return this.LoadWorshipListItemToLive(Selecteditem, SlideNo, TransitionAction, false);
		}
		private bool LoadWorshipListItemToLive(int Selecteditem, int SlideNo, ImageTransitionControl.TransitionAction TransitionAction, bool ReLoadIfCaptureDevice)
		{
			bool result;
			if (gf.AdHocItemPresent)
			{
				if (Selecteditem > 0)
				{
					gf.AdHocItemPresent = false;
				}
				if (Selecteditem > gf.TotalWorshipListItems)
				{
					Selecteditem = gf.TotalWorshipListItems;
				}
			}
			else
			{
				if (gf.TotalWorshipListItems == 0)
				{
					result = false;
					return result;
				}
				if (Selecteditem < 1)
				{
					Selecteditem = 1;
				}
				else
				{
					if (Selecteditem > gf.TotalWorshipListItems)
					{
						Selecteditem = gf.TotalWorshipListItems;
					}
				}
			}
			string inIDString = gf.WorshipSongs[Selecteditem, 0];
			string inFormatString = gf.WorshipSongs[Selecteditem, 4];
			string text = gf.WorshipSongs[Selecteditem, 2];
			gf.LiveItem.CurItemNo = Selecteditem;
			gf.StartPresAt = (gf.AdHocItemPresent ? gf.StartPresAt : gf.LiveItem.CurItemNo);
			gf.LiveItem.Source = ((gf.LiveItem.CurItemNo > 0) ? gf.ItemSource.WorshipList : gf.OutputItem.Source);
			gf.LiveItem.OutputStyleScreen = true;
			gf.LiveItem.AtLiveScreen = true;
			this.LoadItem(ref gf.LiveItem, inIDString, inFormatString, SlideNo, ref text, TransitionAction, ReLoadIfCaptureDevice);
			result = true;
			return result;
		}
		private void MoveToSlideLiveItem(gf.SongSettings InItem, gf.KeyDirection InDirection)
		{
			if (gf.AdvanceNextItem)
			{
				if (InDirection == gf.KeyDirection.PrevOne)
				{
					if (InItem.Type == "G")
					{
						this.MoveToLiveItem(InItem, gf.KeyDirection.Refresh, 30000);
						return;
					}
					if (InItem.CurItemNo > 1 && InItem.CurSlide < 2)
					{
						this.MoveToLiveItem(InItem, gf.KeyDirection.PrevOne, 30000);
						return;
					}
				}
				else
				{
					if (InDirection == gf.KeyDirection.NextOne && InItem.CurItemNo < gf.TotalWorshipListItems)
					{
						if (InItem.CurSlide >= InItem.TotalSlides)
						{
							if (InItem.Type == "P")
							{
								int num = gf.LivePP.ImplementPowerpointSlideMovement(ref InItem.CurSlide, InItem.TotalSlides, gf.ReMapKeyDirectionToPowerpoint(InDirection));
								if (num > 0)
								{
									gf.DrawText(ref InItem, ref this.LiveScreen, InItem.LyricsAndNotationsList, false, false);
									return;
								}
							}
							this.MoveToLiveItem(InItem, gf.KeyDirection.NextOne, 0);
							return;
						}
					}
				}
			}
			if (gf.ShowRunning & InItem.Type == "P")
			{
				gf.LivePP.ImplementPowerpointSlideMovement(ref InItem.CurSlide, InItem.TotalSlides, gf.ReMapKeyDirectionToPowerpoint(InDirection));
				gf.DrawText(ref InItem, ref this.LiveScreen, InItem.LyricsAndNotationsList, false, false);
			}
			else
			{
				if (InDirection == gf.KeyDirection.FirstOne)
				{
					InItem.CurSlide = 1;
				}
				else
				{
					if (InDirection == gf.KeyDirection.PrevOne)
					{
						if (InItem.CurSlide > 2)
						{
							InItem.CurSlide--;
						}
						else
						{
							InItem.CurSlide = 1;
						}
					}
					else
					{
						if (InDirection == gf.KeyDirection.NextOne)
						{
							if (InItem.CurSlide < InItem.TotalSlides)
							{
								InItem.CurSlide++;
							}
							else
							{
								if (gf.GapItemOption == gf.GapType.None)
								{
									InItem.CurSlide = InItem.TotalSlides;
								}
								else
								{
									this.MoveToLiveItem(InItem, gf.KeyDirection.NextOne, 0);
								}
							}
						}
						else
						{
							if (InDirection == gf.KeyDirection.LastOne)
							{
								InItem.CurSlide = InItem.TotalSlides;
							}
						}
					}
				}
				this.ShowSlide(ref InItem, ImageTransitionControl.TransitionAction.AsStored);
			}
		}
		private void LoadItem(ref gf.SongSettings InItem, string InIDString, string InFormatString, int StartingSlide, ref string InTitle, ImageTransitionControl.TransitionAction TransitionAction, bool ReLoadIfCaptureDevice)
		{
			this.Stop_TimerRotate();
			if (gf.RestartItemActioned)
			{
				gf.RestartCurrentItem = false;
			}
			else
			{
				gf.RestartItemActioned = true;
				gf.RestartCurrentItem = true;
			}
			string a = gf.Left(InIDString, 1);
			string prevTitle = "";
			string nextTitle = "";
			bool flag = false;
			if (gf.TotalWorshipListItems > 0)
			{
				int num;
				int num2;
				if (InItem.CurItemNo == 0)
				{
					num = gf.StartPresAt;
					num2 = gf.StartPresAt + 1;
				}
				else
				{
					num = gf.StartPresAt - 1;
					num2 = gf.StartPresAt + 1;
				}
				if (num < 1 && InItem.CurItemNo == 0)
				{
					num = 1;
				}
				if (num2 > gf.TotalWorshipListItems)
				{
					if (InItem.CurItemNo == 0)
					{
						num2 = gf.TotalWorshipListItems;
					}
					else
					{
						num2 = -1;
					}
				}
				if (num == num2)
				{
					if (num == 0)
					{
						num = -1;
					}
				}
				prevTitle = ((num >= 1) ? gf.RemoveMusicSym(gf.WorshipSongs[num, 2]) : "");
				nextTitle = ((num2 >= 1) ? gf.RemoveMusicSym(gf.WorshipSongs[num2, 2]) : "");
			}
			gf.InitialiseIndividualData(ref InItem, (a == "G" && this.Media_NextItemHasSameMedia()) ? gf.GapMedia.SameAsPrevious : gf.GapMedia.SessionMedia, "");
			InItem.PrevTitle = prevTitle;
			InItem.NextTitle = nextTitle;
			gf.LoadIndividualData(ref InItem, InIDString, "", StartingSlide, ref InTitle);
			if (InItem.Type == "I" || a == "G")
			{
				InFormatString = InItem.Format.FormatString;
				TransitionAction = ImageTransitionControl.TransitionAction.AsStored;
			}
			gf.LoadIndividualFormatData(ref InItem, InFormatString);
			if (gf.ShowLiveCam & !this.FirstItemBeingProcessed)
			{
				if (gf.GetMediaLocation(InItem) != gf.CurrentMediaLocation || gf.CurrentMediaLocation == "")
				{
					this.ItemMediaChangedSinceLiveCam = true;
					gf.CurrentMediaLocation = "";
				}
				if (a == "P")
				{
					gf.MinimizePowerPointWindows(ref gf.LivePP);
				}
				flag = true;
			}
			else
			{
				this.ItemMediaChangedSinceLiveCam = true;
			}
			if (a == "P" && !flag)
			{
				this.SetScreenOnTop(false);
				gf.FormatText(ref InItem, gf.PanelBackColour, gf.PanelBackColourTransparent, gf.PanelTextColour, gf.PanelTextColourAsRegion1, InItem.UseDefaultFormat);
				InItem.TotalSlides = gf.RunPowerpointSong(ref InItem, ref gf.LivePP, StartingSlide);
				this.ResetMediaSettings();
				gf.SetTransparentBackground(gf.LiveItem, ref this.LiveScreen);
				InItem.Format.ShowItemTransition = 0;
				InItem.Format.ShowSlideTransition = 0;
				if (gf.ShowLiveCam)
				{
					gf.MinimizePowerPointWindows(ref gf.LivePP);
				}
				else
				{
					gf.DrawText(ref InItem, ref this.LiveScreen, InItem.LyricsAndNotationsList, false, false);
				}
				if (gf.DualMonitorMode && gf.NoPowerpointPanelOverlay)
				{
					this.SetShowWindow(false);
				}
				this.CurItemRotates = false;
				this.ShowSlide(ref gf.LiveItem, ImageTransitionControl.TransitionAction.None, false, true);
				this.RemoteControlMediaPlayerWindow(FrmLaunchShow.MediaPlayerWindowAction.Remote_ClearScreen);
				gf.tbLyricsMonitorSpace.Text = "";
				this.RemoteControlLyricsWindow(FrmLaunchShow.LyricsWindowAction.Remote_ItemChanged);
				this.SetScreenOnTop(true);
			}
			else
			{
				if (a == "D" || a == "B" || a == "T" || a == "I" || a == "W" || a == "M" || a == "G")
				{
					gf.MediaBackgroundStyle mediaBackgroundStyle = gf.GetMediaBackgroundType(InItem, true);
					if (InItem.Format.MediaOption == 3 && ReLoadIfCaptureDevice)
					{
						mediaBackgroundStyle = (gf.MediaCurrentItemIsVideo ? gf.MediaBackgroundStyle.Video : gf.MediaBackgroundStyle.Audio);
					}
					gf.FormatText(ref InItem, gf.PanelBackColour, gf.PanelBackColourTransparent, gf.PanelTextColour, gf.PanelTextColourAsRegion1, InItem.UseDefaultFormat);
					gf.FormatDisplayLyrics(ref InItem, true, true);
					gf.DisplaySlidesFormattedLyrics(ref InItem, ref gf.tbLyricsMonitorSpace, true, gf.LMShowNotations);
					if (flag)
					{
						if (mediaBackgroundStyle != gf.MediaBackgroundStyle.SameAsPrevious)
						{
							this.ItemMediaChangedSinceLiveCam = true;
						}
					}
					else
					{
						gf.MediaBackgroundStyle mediaBackgroundStyle2;
						switch (mediaBackgroundStyle)
						{
						case gf.MediaBackgroundStyle.Audio:
							mediaBackgroundStyle2 = this.RemoteControlMediaPlayerWindow(FrmLaunchShow.MediaPlayerWindowAction.Remote_LoadItem);
							break;
						case gf.MediaBackgroundStyle.Video:
							mediaBackgroundStyle2 = this.RemoteControlMediaPlayerWindow(FrmLaunchShow.MediaPlayerWindowAction.Remote_LoadItem);
							break;
						case gf.MediaBackgroundStyle.SameAsPrevious:
							mediaBackgroundStyle2 = (gf.MediaCurrentItemIsVideo ? gf.MediaBackgroundStyle.Video : gf.MediaBackgroundStyle.Audio);
							this.RemoteControlMediaPlayerWindow(FrmLaunchShow.MediaPlayerWindowAction.Remote_ItemPlayingStatus);
							if (!this.CurMediaPlayingStatus)
							{
								this.RemoteControlMediaPlayerWindow(FrmLaunchShow.MediaPlayerWindowAction.Remote_LoadItem);
							}
							break;
						default:
							this.ResetMediaSettings();
							this.RemoteControlMediaPlayerWindow(FrmLaunchShow.MediaPlayerWindowAction.Remote_StopItem);
							mediaBackgroundStyle2 = gf.MediaBackgroundStyle.None;
							break;
						}
						gf.MediaBackgroundStyle mediaBackgroundStyle3 = mediaBackgroundStyle2;
						if (mediaBackgroundStyle3 != gf.MediaBackgroundStyle.Video)
						{
							gf.MediaCurrentItemIsVideo = false;
							InItem.Format.MediaTransparent = false;
						}
						else
						{
							gf.MediaCurrentItemIsVideo = true;
							InItem.Format.MediaTransparent = true;
						}
						if (gf.ShowLiveCam)
						{
							gf.MinimizePowerPointWindows(ref gf.LivePP);
						}
						else
						{
							this.ShowSlide(ref InItem, TransitionAction, false, true);
						}
						this.RemoteControlLyricsWindow(FrmLaunchShow.LyricsWindowAction.Remote_ItemChanged);
						if (InItem.Format.MediaTransparent)
						{
							gf.MinimizePowerPointWindows(ref gf.LivePP);
						}
						this.tempRotateTimings = "";
						if (gf.AutoRotateOn)
						{
							this.RemoteControlMediaPlayerWindow(FrmLaunchShow.MediaPlayerWindowAction.Remote_ResumeItem);
						}
						else
						{
							if (gf.RestartCurrentItem && mediaBackgroundStyle2 != gf.MediaBackgroundStyle.None)
							{
								this.RemoteControlMediaPlayerWindow(FrmLaunchShow.MediaPlayerWindowAction.Remote_ResumeItemFromStart);
							}
						}
						int rotateStyle = InItem.RotateStyle;
						if (rotateStyle != 1)
						{
							if (InItem.RotateTimings != "" || InItem.RotateTotal >= 0)
							{
								this.Start_ItemRotate(InItem.RotateGap, InItem.RotateTimings, mediaBackgroundStyle2);
							}
							else
							{
								this.CurItemRotates = false;
							}
						}
						else
						{
							if (InItem.RotateGap > 0)
							{
								this.Start_ItemRotate(InItem.RotateGap, "", mediaBackgroundStyle2);
							}
							else
							{
								this.CurItemRotates = false;
							}
						}
						if (this.tempRotateTimings != "" && this.FirstItemLoaded)
						{
							InItem.CurSlide = 1;
						}
						this.FirstItemLoaded = false;
					}
				}
			}
		}
		private bool Media_NextItemHasSameMedia()
		{
			bool result;
			if (gf.CurrentMediaLocation == "" || gf.LiveItem.CurItemNo == gf.TotalWorshipListItems || gf.StartPresAt == gf.TotalWorshipListItems)
			{
				result = false;
			}
			else
			{
				try
				{
					int num = gf.StartPresAt + 1;
					string inTitle = gf.WorshipSongs[num, 2];
					string text = gf.WorshipSongs[num, 1];
					string inTitle2 = "";
					string text2 = gf.WorshipSongs[num, 4];
					if (text == "D")
					{
						inTitle2 = gf.LookupDBTitle2(gf.StringToInt(gf.Mid(gf.WorshipSongs[num, 0], 1)));
					}
					else
					{
						if (text == "I")
						{
							gf.GetTitle2AndFormatFromInfoFile(gf.Mid(gf.WorshipSongs[num, 0], 1), ref inTitle2, ref text2);
						}
					}
					int inMediaOption = gf.StringToInt(gf.ExtractHeaderInfo(text2, 50, '>'));
					bool inUseDefaultFormat = text2 == "";
					string inMediaLocation = gf.ExtractHeaderInfo(text2, 51, '>');
					int inMediaCaptureDeviceNumber = gf.StringToInt(gf.ExtractHeaderInfo(text2, 55, '>'));
					string mediaLocation = gf.GetMediaLocation(inMediaOption, inTitle, inTitle2, inUseDefaultFormat, text, inMediaLocation, inMediaCaptureDeviceNumber);
					if (gf.CurrentMediaLocation == mediaLocation)
					{
						result = true;
					}
					else
					{
						result = false;
					}
				}
				catch
				{
					result = false;
				}
			}
			return result;
		}
		private void ResetMediaSettings()
		{
			gf.CurrentMediaLocation = "";
			gf.CurrentMediaIsVideo = false;
			gf.MediaNotifyRepeatItem = false;
		}
		private void Start_ItemRotate(int InRotateGap, string InRotateTimings, gf.MediaBackgroundStyle MediaBackground)
		{
			this.tempRotateTimings = InRotateTimings;
			if (gf.LiveItem.RotateStyle == 2)
			{
				this.ItemRotationNextTiming = gf.StringToInt(gf.ExtractOneInfo(ref this.tempRotateTimings, ';', true, false));
			}
			else
			{
				this.ItemRotationNextTiming = gf.LiveItem.RotateGap;
			}
			this.ItemRotationNextSlideNumber = 1;
			gf.MediaDoRotate = (MediaBackground != gf.MediaBackgroundStyle.None);
			if (gf.LiveItem.RotateStyle == 2)
			{
				if (gf.LiveItem.RotateTotal == 0)
				{
					if (gf.MediaDoRotate)
					{
						this.RemoteControlMediaPlayerWindow(FrmLaunchShow.MediaPlayerWindowAction.Remote_GetMediaTimings);
						gf.LiveItem.RotateTotal = this.intLiveMediaDuration;
					}
					else
					{
						int num = 1;
						while (InRotateTimings.Length > 0)
						{
							int num2 = gf.StringToInt(gf.ExtractOneInfo(ref InRotateTimings, ';', true, false));
							if (num2 > num)
							{
								num = num2;
							}
						}
						gf.LiveItem.RotateTotal = num + 10;
					}
				}
				else
				{
					this.RemoteControlMediaPlayerWindow(FrmLaunchShow.MediaPlayerWindowAction.Remote_GetMediaTimings);
					int num3 = this.intLiveMediaDuration;
					if (num3 != gf.LiveItem.RotateTotal)
					{
						gf.MediaDoRotate = false;
					}
				}
			}
			gf.MediaLiveItemStartTime = DateTime.Now;
			this.CurItemRotates = true;
			this.TimerRotate.Start();
		}
		private void Stop_TimerRotate()
		{
			this.TimerRotate.Stop();
			this.tempRotateTimings = "";
		}
		private void TimerRotate_Tick(object sender, EventArgs e)
		{
			if ((gf.AutoRotateOn && this.CurItemRotates) || gf.RestartCurrentItem)
			{
				if (!gf.MediaDoRotate)
				{
					gf.MediaPlayedLapseTime = DateTime.Now.Subtract(gf.MediaLiveItemStartTime);
				}
				this.DoRotate();
			}
			else
			{
				this.TimerRotate.Stop();
			}
		}
		private void DoRotate()
		{
			switch (gf.LiveItem.RotateStyle)
			{
			case 1:
				if (gf.LiveItem.RotateGap < 0)
				{
					this.TimerRotate.Stop();
				}
				else
				{
					if (gf.MediaPlayedLapseTime.TotalSeconds > 0.0 && gf.MediaPlayedLapseTime.TotalSeconds >= (double)this.ItemRotationNextTiming)
					{
						if (gf.LiveItem.CurSlide < gf.LiveItem.TotalSlides)
						{
							gf.LiveItem.CurSlide++;
							this.MoveToSlideLiveItem(gf.LiveItem, gf.KeyDirection.Refresh);
							this.ItemRotationNextTiming += gf.LiveItem.RotateGap;
							if (gf.ShowRunning)
							{
                                //this.OnMessage(9, "");
							}
						}
						else
						{
							this.TimerRotate.Stop();
							int num = this.ImplementAutoRotateOption();
							if (num >= 0)
							{
								if (num == gf.LiveItem.CurItemNo)
								{
									this.ItemRotationNextTiming = (int)gf.MediaPlayedLapseTime.TotalSeconds + gf.LiveItem.RotateGap;
									gf.LiveItem.CurSlide = 1;
									this.MoveToSlideLiveItem(gf.LiveItem, gf.KeyDirection.Refresh);
									if (gf.ShowRunning)
									{
                                        //this.OnMessage(9, "");
									}
									this.TimerRotate.Start();
								}
								else
								{
									this.prevRefMode = gf.ReferenceAlertSource;
									gf.ReferenceAlertSource = ((num == gf.LiveItem.CurItemNo) ? 0 : gf.ReferenceAlertSource);
									this.LoadWorshipListItemToLive(num, 1, ImageTransitionControl.TransitionAction.AsStored);
									gf.MediaLiveItemStartTime = DateTime.Now;
									gf.ReferenceAlertSource = this.prevRefMode;
									if (gf.ShowRunning)
									{
                                        //this.OnMessage(7, "");
									}
								}
							}
							else
							{
								if (gf.GapItemOption != gf.GapType.None)
								{
									gf.StartPresAt = (gf.AdHocItemPresent ? gf.StartPresAt : gf.LiveItem.CurItemNo);
									gf.Launch_StartPresAt = gf.StartPresAt;
									this.MoveToLiveItem(gf.LiveItem, gf.KeyDirection.NextOne);
									if (gf.ShowRunning)
									{
                                        //this.OnMessage(8, "");
									}
								}
							}
						}
					}
				}
				break;
			case 2:
				if ((gf.MediaPlayedLapseTime.TotalSeconds > 0.0 && gf.MediaPlayedLapseTime.TotalSeconds >= (double)this.ItemRotationNextTiming) || gf.MediaPlayedLapseTime.TotalSeconds >= (double)gf.LiveItem.RotateTotal)
				{
					if (gf.MediaPlayedLapseTime.TotalSeconds >= (double)gf.LiveItem.RotateTotal)
					{
						this.TimerRotate.Stop();
						int num = this.ImplementAutoRotateOption();
						if (num >= 0)
						{
							this.prevRefMode = gf.ReferenceAlertSource;
							gf.ReferenceAlertSource = ((num == gf.LiveItem.CurItemNo) ? 0 : gf.ReferenceAlertSource);
							if (gf.MediaLengthAsRotateLength)
							{
								this.RemoteControlMediaPlayerWindow(FrmLaunchShow.MediaPlayerWindowAction.Remote_StopItem);
							}
							this.LoadWorshipListItemToLive(num, 1, ImageTransitionControl.TransitionAction.AsStored);
							gf.MediaLiveItemStartTime = DateTime.Now;
							gf.ReferenceAlertSource = this.prevRefMode;
							if (gf.ShowRunning)
							{
                                //this.OnMessage(7, "");
							}
						}
						else
						{
							if (gf.GapItemOption != gf.GapType.None)
							{
								gf.StartPresAt = (gf.AdHocItemPresent ? gf.StartPresAt : gf.LiveItem.CurItemNo);
								gf.Launch_StartPresAt = gf.StartPresAt;
								this.MoveToLiveItem(gf.LiveItem, gf.KeyDirection.NextOne);
								if (gf.ShowRunning)
								{
                                    //this.OnMessage(8, "");
								}
							}
						}
					}
					else
					{
						if (this.ItemRotationNextSlideNumber < gf.LiveItem.TotalSlides && this.ItemRotationNextTiming > 0)
						{
							this.ItemRotationNextSlideNumber++;
							gf.LiveItem.CurSlide = this.ItemRotationNextSlideNumber;
							this.MoveToSlideLiveItem(gf.LiveItem, gf.KeyDirection.Refresh);
							if (gf.ShowRunning)
							{
                                //this.OnMessage(9, "");
							}
						}
						this.ItemRotationNextTiming = gf.StringToInt(gf.ExtractOneInfo(ref this.tempRotateTimings, ';', true, false));
						if (this.ItemRotationNextTiming <= 0)
						{
							this.ItemRotationNextTiming = gf.LiveItem.RotateTotal;
						}
					}
				}
				break;
			}
		}
		private int ImplementAutoRotateOption()
		{
			int result;
			if (gf.RestartCurrentItem)
			{
				result = -1;
			}
			else
			{
				if (gf.AutoRotateOn)
				{
					switch (gf.AutoRotateStyle)
					{
					case 0:
						result = -1;
						break;
					case 1:
						result = (gf.AdHocItemPresent ? 0 : gf.StartPresAt);
						break;
					case 2:
					{
						int num = this.Rotate_FindNextItem(false);
						if (num == gf.LiveItem.CurItemNo)
						{
							result = -1;
						}
						else
						{
							gf.StartPresAt = num;
							result = gf.StartPresAt;
						}
						break;
					}
					default:
					{
						int num = this.Rotate_FindNextItem(true);
						if (num == gf.LiveItem.CurItemNo)
						{
							result = gf.LiveItem.CurItemNo;
						}
						else
						{
							gf.StartPresAt = num;
							result = gf.StartPresAt;
						}
						break;
					}
					}
				}
				else
				{
					result = -1;
				}
			}
			return result;
		}
		private int Rotate_FindNextItem(bool GetPreviousIfNoNext)
		{
			int result;
			if (gf.LiveItem.CurItemNo == gf.TotalWorshipListItems || gf.StartPresAt == gf.TotalWorshipListItems)
			{
				if (GetPreviousIfNoNext)
				{
					result = this.Rotate_FindPreviousItem(gf.LiveItem.CurItemNo);
				}
				else
				{
					result = gf.LiveItem.CurItemNo;
				}
			}
			else
			{
				try
				{
					int num = gf.StartPresAt + 1;
					int itemRotateResult = gf.GetItemRotateResult(gf.WorshipSongs[num, 0]);
					if (itemRotateResult > 0)
					{
						if (itemRotateResult == 2)
						{
							try
							{
							}
							catch
							{
							}
						}
						result = gf.StartPresAt + 1;
						return result;
					}
					if (gf.AdHocItemPresent && GetPreviousIfNoNext)
					{
						int num2 = gf.StartPresAt;
						try
						{
							num2 = gf.GetItemRotateResult(gf.WorshipSongs[gf.StartPresAt, 0]);
						}
						catch
						{
						}
						int num3 = this.Rotate_FindPreviousItem(gf.StartPresAt);
						if (num2 < 1)
						{
							result = gf.LiveItem.CurItemNo;
							return result;
						}
						result = num3;
						return result;
					}
				}
				catch
				{
				}
				if (GetPreviousIfNoNext)
				{
					result = this.Rotate_FindPreviousItem(gf.LiveItem.CurItemNo);
				}
				else
				{
					result = gf.LiveItem.CurItemNo;
				}
			}
			return result;
		}
		private int Rotate_FindPreviousItem(int InItemNo)
		{
			int result;
			if (InItemNo <= 1)
			{
				result = InItemNo;
			}
			else
			{
				try
				{
					int num = InItemNo - 1;
					int itemRotateResult = gf.GetItemRotateResult(gf.WorshipSongs[num, 0]);
					if (itemRotateResult > 0)
					{
						if (itemRotateResult == 2)
						{
							try
							{
								this.RemoteControlMediaPlayerWindow(FrmLaunchShow.MediaPlayerWindowAction.Remote_StopItem);
							}
							catch
							{
							}
						}
						result = this.Rotate_FindPreviousItem(InItemNo - 1);
						return result;
					}
				}
				catch
				{
				}
				result = InItemNo;
			}
			return result;
		}
		private void FrmLaunchShow_VisibleChanged(object sender, EventArgs e)
		{
			if (base.Visible)
			{
				if (this.FormFirstLoad)
				{
					this.FormFirstLoad = false;
				}
				else
				{
					this.InitForm();
				}
				base.Activate();
			}
		}
		private gf.MediaBackgroundStyle RemoteControlMediaPlayerWindow(FrmLaunchShow.MediaPlayerWindowAction InAction)
		{
			gf.MediaBackgroundStyle result = gf.MediaBackgroundStyle.None;
			try
			{
				switch (InAction)
				{
				case FrmLaunchShow.MediaPlayerWindowAction.Show:
					this.MediaPlayerWindow.Show();
					break;
				case FrmLaunchShow.MediaPlayerWindowAction.SendToBack:
					this.MediaPlayerWindow.SendToBack();
					break;
				case FrmLaunchShow.MediaPlayerWindowAction.Remote_StopShow:
					this.MediaPlayerWindow.Remote_StopShow();
					break;
				case FrmLaunchShow.MediaPlayerWindowAction.Remote_ClearScreen:
					this.MediaPlayerWindow.Remote_ClearScreen();
					break;
				case FrmLaunchShow.MediaPlayerWindowAction.Remote_LoadItem:
					result = (gf.MediaBackgroundStyle)this.MediaPlayerWindow.Remote_LoadItem();
					break;
				case FrmLaunchShow.MediaPlayerWindowAction.Remote_ResumeItem:
					result = (gf.MediaBackgroundStyle)this.MediaPlayerWindow.Remote_ResumeItem();
					break;
				case FrmLaunchShow.MediaPlayerWindowAction.Remote_RepeatItem:
					result = (gf.MediaBackgroundStyle)this.MediaPlayerWindow.Remote_RepeatItem();
					break;
				case FrmLaunchShow.MediaPlayerWindowAction.Remote_StopItem:
					this.MediaPlayerWindow.Remote_StopItem();
					break;
				case FrmLaunchShow.MediaPlayerWindowAction.Remote_ResumeItemFromStart:
					this.MediaPlayerWindow.Remote_ResumeItemFromStart();
					break;
				case FrmLaunchShow.MediaPlayerWindowAction.Remote_PauseItem:
					this.MediaPlayerWindow.Remote_PauseItem();
					break;
				case FrmLaunchShow.MediaPlayerWindowAction.Remote_PausePlayItem:
					this.MediaPlayerWindow.Remote_PausePlayItem();
					break;
				case FrmLaunchShow.MediaPlayerWindowAction.Remote_LoadLiveCam:
					result = (gf.MediaBackgroundStyle)this.MediaPlayerWindow.Remote_LoadLiveCam();
					break;
				case FrmLaunchShow.MediaPlayerWindowAction.Remote_UpdateLiveCam:
					result = (gf.MediaBackgroundStyle)this.MediaPlayerWindow.Remote_UpdateLiveCam();
					break;
				case FrmLaunchShow.MediaPlayerWindowAction.Remote_RefreshMediaWindow:
					this.MediaPlayerWindow.Remote_RefreshMediaWindow();
					break;
				case FrmLaunchShow.MediaPlayerWindowAction.Remote_SendScreenToBack:
					this.MediaPlayerWindow.Remote_SendScreenToBack();
					break;
				case FrmLaunchShow.MediaPlayerWindowAction.Remote_GetMediaTimings:
					this.MediaPlayerWindow.Remote_GetMediaTimings(ref this.LiveMediaDuration, ref this.LiveMediaPosition, ref this.intLiveMediaDuration, ref this.intLiveMediaPosition);
					break;
				case FrmLaunchShow.MediaPlayerWindowAction.Remote_ItemPlayingStatus:
					this.CurMediaPlayingStatus = this.MediaPlayerWindow.Remote_ItemPlayingStatus();
					break;
				}
			}
			catch
			{
				try
				{
					this.MediaPlayerWindow = new FrmLaunchMediaPlayer();
					this.MediaPlayerWindow.OnMessage += new FrmLaunchMediaPlayer.Message(this.MediaPlayerWindow_OnMessage);
					result = this.RemoteControlMediaPlayerWindow(InAction);
				}
				catch
				{
				}
			}
			return result;
		}
		private void RemoteControlLyricsWindow(FrmLaunchShow.LyricsWindowAction InAction)
		{
			if (gf.LyricsMonitorNumber > 0 || gf.LMOption > 0)
			{
				try
				{
					switch (InAction)
					{
					case FrmLaunchShow.LyricsWindowAction.Show:
						this.LyricsWindow.Show();
						break;
					case FrmLaunchShow.LyricsWindowAction.Remote_StopShow:
						this.LyricsWindow.Remote_StopShow();
						break;
					case FrmLaunchShow.LyricsWindowAction.Remote_LyricsChanged:
						this.LyricsWindow.Remote_LyricsChanged();
						break;
					case FrmLaunchShow.LyricsWindowAction.Remote_ItemChanged:
						this.LyricsWindow.Remote_ItemChanged();
						break;
					case FrmLaunchShow.LyricsWindowAction.Remote_NotationsChanged:
						this.LyricsWindow.Remote_NotationsChanged();
						break;
					case FrmLaunchShow.LyricsWindowAction.Remote_WorshipListChanged:
						this.LyricsWindow.Remote_WorshipListChanged();
						break;
					case FrmLaunchShow.LyricsWindowAction.Remote_LyricsAlertChanged:
						this.LyricsWindow.Remote_LyricsAlertChanged();
						break;
					}
				}
				catch
				{
					try
					{
						this.LyricsWindow = new FrmLyricsScreen();
						this.LyricsWindow.OnMessage += new FrmLyricsScreen.Message(this.LyricsWindow_OnMessage);
						this.RemoteControlLyricsWindow(InAction);
					}
					catch
					{
					}
				}
			}
		}
		private void FrmLaunchShow_Enter(object sender, EventArgs e)
		{
			this.CursorOverForm = true;
		}
		private void FrmLaunchShow_Leave(object sender, EventArgs e)
		{
			this.CursorOverForm = false;
		}
		private void GotoNextNonRotateItem()
		{
			int nextNonRotateItem = gf.GetNextNonRotateItem(gf.LiveItem.Type == "G");
			bool flag = false;
			if (gf.GapItemOption == gf.GapType.None)
			{
				if (nextNonRotateItem != gf.StartPresAt)
				{
					gf.StartPresAt = nextNonRotateItem;
					this.MoveToLiveItem(gf.LiveItem, gf.KeyDirection.Refresh);
				}
			}
			else
			{
				if (nextNonRotateItem == gf.StartPresAt)
				{
					if (gf.LiveItem.Type != "G")
					{
						flag = true;
					}
				}
				else
				{
					if (nextNonRotateItem > 1)
					{
						flag = true;
					}
				}
			}
			if (flag)
			{
				gf.StartPresAt = nextNonRotateItem;
				gf.Launch_StartPresAt = gf.StartPresAt;
				string text = "";
				this.LoadItem(ref gf.LiveItem, "G1", "", 0, ref text, ImageTransitionControl.TransitionAction.None, false);
			}
		}
		private void TimerToFront_Tick(object sender, EventArgs e)
		{
			if (gf.DualMonitorMode)
			{
				this.TimerToFront.Stop();
			}
			else
			{
				if (this.LoadRepaintCount > 8)
				{
					this.TimerToFront.Stop();
					base.Focus();
					base.TopMost = false;
				}
				else
				{
					this.LoadRepaintCount++;
				}
			}
		}
	}
}
